package com.itheima.d1_properties;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

/*
    目标：掌握把键值对数据存入到属性文件中去
        public void store(OutputStream os, String comments)	把键值对数据，通过字节输出流写出到属性文件里去
        public void store(Writer w, String comments)	把键值对数据，通过字符输出流写出到属性文件里去
        public void load(InputStream is)	通过字节输入流，读取属性文件里的键值对数据
        public void load(Reader reader)	通过字符输入流，读取属性文件里的键值对数据
 */
public class PropertiesTest2 {
    public static void main(String[] args) throws IOException {
        store();
//        Properties prop = new Properties();
//        System.out.println(prop);
//        prop.load(new FileReader("user.properties"));
//        prop.load(new FileReader("aaa.txt"));
//        System.out.println(prop);
    }

    private static void store() throws IOException {
        Properties prop = new Properties();

        prop.setProperty("zhangsan","24");
        prop.setProperty("李四","22");
        prop.setProperty("wangwu","299");

        System.out.println(prop);
        prop.store(new FileWriter("user.properties"),"xixi");
    }
}
